/**
 * https://leetcode.cn/problems/max-consecutive-ones/
 * @param nums
 */
function findMaxConsecutiveOnes(nums: number[]): number {
  if (nums.length === 0) return 0;
  let maxLength = 0,
    oneLength = 0;

  for (let i = 0; i < nums.length; i++) {
    if (nums[i] === 1) {
      oneLength++;
    } else {
      oneLength = 0
      maxLength = Math.max(oneLength, maxLength)
    }
  }

  return maxLength;
}
